Reflection
Example
package main
import (
"fmt"
"reflect"
)
func main() {
student := Student{26, "Test"}
myType := reflect.TypeOf(student)
fmt.Println(myType.Name()) // Student
fmt.Println(myType.Kind()) // struct
fmt.Println(myType.NumField()) // 2
fmt.Println(myType.Field(0).Name) // Age
}
type Student struct {
Age int
Name string
}